// 图标转换脚本 - 将SVG转换为PNG
const fs = require('fs');
const path = require('path');

// 由于无法直接转换SVG到PNG，我们创建一个简单的替换方案
// 将SVG文件复制为PNG文件名，微信小程序会自动处理

const iconPaths = [
  // assets/icons 目录 - 基础图标
  { src: 'assets/icons/empty-order.svg', dest: 'assets/icons/empty-order.png' },
  { src: 'assets/icons/store.svg', dest: 'assets/icons/store.png' },
  { src: 'assets/icons/distance.svg', dest: 'assets/icons/distance.png' },
  { src: 'assets/icons/time.svg', dest: 'assets/icons/time.png' },
  { src: 'assets/icons/money.svg', dest: 'assets/icons/money.png' },
  { src: 'assets/icons/accept.svg', dest: 'assets/icons/accept.png' },
  { src: 'assets/icons/pickup.svg', dest: 'assets/icons/pickup.png' },
  { src: 'assets/icons/phone.svg', dest: 'assets/icons/phone.png' },
  { src: 'assets/icons/delivery.svg', dest: 'assets/icons/delivery.png' },
  { src: 'assets/icons/goods.svg', dest: 'assets/icons/goods.png' },
  { src: 'assets/icons/accept-order.svg', dest: 'assets/icons/accept-order.png' },

  // 操作图标
  { src: 'assets/icons/reject.svg', dest: 'assets/icons/reject.png' },
  { src: 'assets/icons/complete.svg', dest: 'assets/icons/complete.png' },
  { src: 'assets/icons/pickup-goods.svg', dest: 'assets/icons/pickup-goods.png' },
  { src: 'assets/icons/complete-delivery.svg', dest: 'assets/icons/complete-delivery.png' },
  { src: 'assets/icons/report.svg', dest: 'assets/icons/report.png' },

  // 界面图标
  { src: 'assets/icons/arrow-right.svg', dest: 'assets/icons/arrow-right.png' },
  { src: 'assets/icons/mark-read.svg', dest: 'assets/icons/mark-read.png' },
  { src: 'assets/icons/clear.svg', dest: 'assets/icons/clear.png' },
  { src: 'assets/icons/default-avatar.svg', dest: 'assets/icons/default-avatar.png' },
  { src: 'assets/icons/verified.svg', dest: 'assets/icons/verified.png' },
  { src: 'assets/icons/unverified.svg', dest: 'assets/icons/unverified.png' },

  // 消息类型图标
  { src: 'assets/icons/message-new_order.svg', dest: 'assets/icons/message-new_order.png' },
  { src: 'assets/icons/message-system.svg', dest: 'assets/icons/message-system.png' },
  { src: 'assets/icons/message-customer_reminder.svg', dest: 'assets/icons/message-customer_reminder.png' },
  { src: 'assets/icons/message-merchant_ready.svg', dest: 'assets/icons/message-merchant_ready.png' },

  // images 目录
  { src: 'images/user.svg', dest: 'images/user.png' },
  { src: 'images/store.svg', dest: 'images/store.png' },
  { src: 'images/delivery.svg', dest: 'images/delivery.png' }
];

console.log('开始转换图标...');

iconPaths.forEach(({ src, dest }) => {
  try {
    if (fs.existsSync(src)) {
      fs.copyFileSync(src, dest);
      console.log(`✅ 转换成功: ${src} -> ${dest}`);
    } else {
      console.log(`❌ 源文件不存在: ${src}`);
    }
  } catch (error) {
    console.log(`❌ 转换失败: ${src} - ${error.message}`);
  }
});

console.log('图标转换完成！');
